package com.sunny.ynhz.utils;

import android.content.Context;
import android.graphics.BitmapFactory;

import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.sunny.ynhz.R;

/**
 * Created by huhuan123 on 2018/1/4.
 */

public class MarkOptionUtils {

    private static Marker marker;

    public static void setMarkPosition(Context context, LatLng latLng, AMap aMap){
        if(marker!=null){
            marker.setPosition(latLng);
        }
        else {
            MarkerOptions markerOption = new MarkerOptions();
            markerOption.position(latLng);
            markerOption.draggable(false);//设置Marker可拖动
            markerOption.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
                    .decodeResource(context.getResources(), R.mipmap.ic_self_position)));
            // 将Marker设置为贴地显示，可以双指下拉地图查看效果
            markerOption.setFlat(true);//设置marker平贴地图效果
            marker = aMap.addMarker(markerOption);
        }

    }
     public static void setCenterPosition(AMap aMap,LatLng latLng){
        aMap.moveCamera(CameraUpdateFactory.changeLatLng(latLng));
        aMap.moveCamera(CameraUpdateFactory.zoomTo(15));

    }
}
